window.onload = function() {
    // 退出账号
    var quit = document.getElementById("quit")
    quit.onclick = function() {

        if (confirm('您确定要退出该账号吗?')) {
            console.log("11111")
            localStorage.removeItem("************")
            window.location.href = "z-login.html"
                // localStorage.setItem("************", "null")

        }
    }

    var exit = document.getElementById('exit')
    exit.onclick = function() {
        if (confirm('您确定要退出吗?')) {
            localStorage.removeItem("************")
            window.location.href = 'z-login.html'
        }
    }


    var id = document.getElementById('txt1'); //编号
    var xname = document.getElementById('txt2'); //姓名
    var address = document.getElementById('txt3'); //地址
    var add = document.getElementById('add'); //添加按钮
    var tbody = document.getElementById('body');
    //添加点击事件
    add.onclick = function() {
        var tr = createTr();
        tbody.appendChild(tr);
        for (var i = 0; i < document.getElementsByTagName("input").length; i++) {
            document.getElementsByTagName("input")[i].value = ""
        }
    };

    function createTr() {
        var tr = document.createElement('tr');
        var td1 = createCell(id.value, false);
        var td2 = createCell(xname.value, false);
        var td3 = createCell(address.value, false);
        var td4 = createCell("取消  ", true);
        tr.appendChild(td1);
        tr.appendChild(td2);
        tr.appendChild(td3);
        tr.appendChild(td4);
        return tr;
    }

    function createCell(value, isLink) {
        var cell = document.createElement('td');
        if (isLink) {
            var link = document.createElement('a');
            link.href = '#';
            link.innerHTML = value;
            cell.appendChild(link);
            //点击删除时，删除一行
            link.onclick = function() {
                if (confirm('您确定要取消预约吗?')) {
                    var tr = this.parentNode.parentNode;
                    tr.parentNode.removeChild(tr);
                }
            }
        } else {
            cell.innerHTML = value;
        }

        return cell;
    }


}